﻿/// <reference path="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\MicrosoftAjax.js" />
/// <reference path="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033\init.debug.js" />
/// <reference path="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\SP.debug.js" />
/// <reference path="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\SP.Ribbon.debug.js" />
/// <reference path="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\SP.Core.debug.js" />
/// <reference path="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\SP.UI.debug.js" />
/// <reference path="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\SP.UI.RTE.debug.js" />
/// <reference path="C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\SP.UI.Dialog.debug.js" />

DemoSite = {
    Components: {},
    initializePage: function () {
        SP.UI.Notify.addNotification('Initializing the page', false);
        $j('[data-constructor]').each(function () {
            var dataElement = $j(this);
            if (!dataElement.data('instantiated')) {
                var ctorName = dataElement.attr('data-constructor');
                if (DemoSite.Components[ctorName] !== undefined) {
                    var component = new DemoSite.Components[ctorName](dataElement);
                    SP.Ribbon.PageManager.get_instance().addPageComponent(component);
                    dataElement.attr('data-instantiated', true);
                }
            }
        });
    }
};

DemoSite.PageComponent = function (element) {
    DemoSite.PageComponent.initializeBase(this);
    this.element = element;
};
DemoSite.PageComponent.prototype = {
    element: null
};

DemoSite.Components.DemoWebPart = function (element) {
    DemoSite.Components.DemoWebPart.initializeBase(this, [element]);
};
DemoSite.Components.DemoWebPart.prototype = {
    init: function () {
        SP.UI.Notify.addNotification('Initializing demo web part', false);
    }
};

DemoSite.PageComponent.registerClass('DemoSite.PageComponent', CUI.Page.PageComponent);
DemoSite.Components.DemoWebPart.registerClass('DemoSite.Components.DemoWebPart', DemoSite.PageComponent);

if (typeof (Sys) != "undefined" && Sys && Sys.Application) {
    Sys.Application.notifyScriptLoaded();
}
if (typeof (SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs) == "function") {
    SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs("demosite.js");
}